package org.example.config;

import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.security.web.access.AccessDeniedHandler;

import java.io.IOException;

class CustomAuthenticationEntryPoint implements AuthenticationEntryPoint,
        AccessDeniedHandler {
 @Override
 public void commence(HttpServletRequest request, HttpServletResponse response,
  AuthenticationException authException) throws IOException,
         ServletException {
     request.getRequestDispatcher("/403").forward(request,response);
 }
 @Override
 public void handle(HttpServletRequest request, HttpServletResponse response,
                    AccessDeniedException accessDeniedException) throws IOException, ServletException {
  }


}
